package edu.chinasoft.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.annotation.WebServlet;
import org.apache.log4j.Logger;

import edu.chinasoft.pojo.Province;
import edu.chinasoft.service.ProvinceService;
import edu.chinasoft.service.ProvinceServiceImp;

/**
 *
 * @author mhao
 * @date 2020年2月12日:下午3:56:48
 * @version V1.0
 * @Description: 
*/
@WebServlet(name = "", value = "")
public class FindAllProcinceServlet extends HttpServlet {
	private static Logger logger = Logger.getLogger(FindAllProcinceServlet.class);
	private ProvinceService provinceService=new ProvinceServiceImp();
	/**
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logger.debug(" FindAllProcinceServlet >doGet start.......");
		response.setContentType("test/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		//通过调用服务层方法把所有的省获取到
		List<Province> AllProvince=provinceService.findAllProvince();
		//把省数据保存到域里
		HttpSession session = request.getSession();
		session.setAttribute("allProvince", AllProvince);
		//跳转到jsp页面中
		request.getRequestDispatcher("/provincecity02.jsp").forward(request, response);  //请求转发
		//response.sendRedirect(""+request.getContextPath()+"/jsp001.jsp");     请求重发
		logger.debug(" FindAllProcinceServlet >doGet end.......");
	}

	/**
	 *
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logger.debug(" FindAllProcinceServlet >doPost start.......");
		this.doGet(request, response);
		logger.debug(" FindAllProcinceServlet >doPost end.......");
	}

}